<template>
	<!-- 优惠券 -->
	<view class="">
		<view v-if="dataList.length > 0" class="content">
			<view v-for="item in dataList" class="con-card">
				<view class="card-right">
					<view class="right-top">
						{{item.name}}
					</view>
					<view class="right-center">
						<text v-if="item.type !== 'EMPTY'">使用范围：69商城通用</text>
						{{obj[item.type]}}
					</view>
					<view class="right-bot">
						获取时间：{{item.createdDate}}
					</view>
					<view v-if="item.isExpired" class="onend">
						<image src="https://image.hzwltb69.com/app/date/2023/onend.png" alt="">
					</view>
				</view>
			</view>
			<u-loadmore height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
		</view>
		<view v-else class="nomore">
			<ljshop-empty :image="`https://image.hzwltb69.com/app/date/2023/暂无商品.png`" ></ljshop-empty>
			<view class="">
				暂无中奖记录
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				dataList:[],
				page: 0,
				loadStatus: 'nomore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				obj:{
					EMPTY: '谢谢惠顾',
					COUPON: '券',
					POINT: '积分'
				}
			}
		},
		onReachBottom() {
			this.page += 1
			this.getList()
		},
		created() {
			this.getList()
		},
		methods:{
			getList(){
				this.$http('coupons.getPrizeHistory',{
					UId: uni.getStorageSync('UId'),
					page: this.page,
					size: 10
				})
				.then(res=>{
					if(res.list.length > 0){
						this.dataList.length == 0 ? this.dataList = res.list : this.dataList = this.dataList.concat(res.list)
						if(res.list.length < 10){
							this.onEnd = true
							this.loadStatus = 'nomore'
						}else{
							this.loadStatus = 'loadmore'
						}
					}else{
						this.onEnd = true
						this.loadStatus = 'nomore'
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding: 20rpx;
		text-align: center;
		.con-card{
			height: 200rpx;
			width: 100%;
			border-radius: 25rpx;
			display: flex;
			margin-bottom: 20rpx;
			.card-right{
				width: 100%;
				margin-left: 10rpx;
				background: #fff;
				height: 100%;
				border-radius: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				font-size: 25rpx;
				text-align: start;
				color: #B9B9B9;
				padding-left: 20rpx;
				position: relative;
				.onend{
					position: absolute;
					width: 100rpx;
					height: 100rpx;
					top: 20rpx;
					right: 20rpx;
					// background-color: skyblue;
					image{
						width: 100%;
						height: 100%;
					}
				}
				.right-top{
					color: #666666;
				}
				.right-center{
					margin-top: 15rpx;
					margin-bottom: 15rpx;
				}
			}
		}
		.bgc-yellow{
			background: linear-gradient(150deg,#ffdd8c,#fea026) !important;
		}
		.bgc-none{
			background: #d2d2d2 !important;
		}
	}
	.nomore{
		padding-top: 200rpx;
		width: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #666666;
		font-size: 25rpx;
	}
</style>